package cn.dada.dadarecipes.mall.productreview.controller;

import cn.dada.dadarecipes.base.response.JsonResult;
import cn.dada.dadarecipes.mall.productreview.pojo.dto.AddCommentParam;
import cn.dada.dadarecipes.mall.productreview.pojo.vo.ProductReviewVO;
import cn.dada.dadarecipes.mall.productreview.service.ProductReviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "03.04商品评价模块")
@Slf4j
@RestController
@RequestMapping("/v1/productReview")
public class productReviewController {

    @Autowired
    ProductReviewService productReviewService;

    @ApiOperation(value = "商品评价查询功能")
    @GetMapping("/selectComment/{productId}")
    public JsonResult selectComment(@PathVariable Long productId) {
        log.debug("商品评价查询功能:{}", productId);
        List<ProductReviewVO> productReviewVOS = productReviewService.selectComment(productId);
        return JsonResult.ok(productReviewVOS);
    }

    @ApiOperation(value = "新增评价功能")
    @PostMapping("addComment")
    public JsonResult selectComment2(AddCommentParam addCommentParam) {
        log.debug("新增评论功能:{}", addCommentParam);
        productReviewService.addComment(addCommentParam);
        return JsonResult.ok();
    }

    @ApiOperation(value = "删除评论功能")
    @PostMapping("/delete/{id}")
    public JsonResult deleteComment(@PathVariable Long id) {
        log.debug("删除评论功能:{}", id);
        productReviewService.deleteComment(id);
        return JsonResult.ok();
    }






}
